package com.serviceprovider.business.module.admin.license.model;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.admin.acl.utility.AbstractEntity;

/**
 * Represents a relationship between Role and License , also describe rules that user of a role need to follows
 * (eg.Accepting a license may be required at next login)
 */
@SuppressWarnings("serial")
public class LicenseRoleApply extends AbstractEntity {
    private boolean announceLinkOnNewsPage;
    private int     licenseId;
    private boolean mandatoryAtNewRegistration;
    private boolean mandatoryAtNextLogin;
    private boolean mandatoryBeforeNextOrder;
    private int     roleId;
    private boolean silentCreation;
    private boolean silentUpdate;

    @Override
    public boolean equals(Object obj) {
        if ((obj == null) ||!(obj instanceof LicenseRoleApply)) {
            return false;
        }

        LicenseRoleApply b = (LicenseRoleApply) obj;

        if (licenseId != b.licenseId) {
            return false;
        }

        if (roleId != b.roleId) {
            return false;
        }

        if (silentCreation != b.silentCreation) {
            return false;
        }

        if (silentUpdate != b.silentUpdate) {
            return false;
        }

        if (announceLinkOnNewsPage != b.announceLinkOnNewsPage) {
            return false;
        }

        if (mandatoryAtNewRegistration != b.mandatoryAtNewRegistration) {
            return false;
        }

        if (mandatoryAtNextLogin != b.mandatoryAtNextLogin) {
            return false;
        }

        if (mandatoryBeforeNextOrder != b.mandatoryBeforeNextOrder) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int prime  = 31;
        int result = 1;

        result = prime * result + licenseId;
        result = prime * result + roleId;
        result = prime * result + ((silentCreation == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((silentUpdate == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((announceLinkOnNewsPage == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((mandatoryAtNewRegistration == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((mandatoryAtNextLogin == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((mandatoryBeforeNextOrder == false)
                                   ? 0
                                   : 1);

        return result;
    }

    public int getLicenseId() {
        return licenseId;
    }

    public void setLicenseId(int licenseId) {
        this.licenseId = licenseId;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public boolean isSilentCreation() {
        return silentCreation;
    }

    public void setSilentCreation(boolean silentCreation) {
        this.silentCreation = silentCreation;
    }

    public boolean isSilentUpdate() {
        return silentUpdate;
    }

    public void setSilentUpdate(boolean silentUpdate) {
        this.silentUpdate = silentUpdate;
    }

    public boolean isAnnounceLinkOnNewsPage() {
        return announceLinkOnNewsPage;
    }

    public void setAnnounceLinkOnNewsPage(boolean announceLinkOnNewsPage) {
        this.announceLinkOnNewsPage = announceLinkOnNewsPage;
    }

    public boolean isMandatoryAtNewRegistration() {
        return mandatoryAtNewRegistration;
    }

    public void setMandatoryAtNewRegistration(boolean mandatoryAtNewRegistration) {
        this.mandatoryAtNewRegistration = mandatoryAtNewRegistration;
    }

    public boolean isMandatoryAtNextLogin() {
        return mandatoryAtNextLogin;
    }

    public void setMandatoryAtNextLogin(boolean mandatoryAtNextLogin) {
        this.mandatoryAtNextLogin = mandatoryAtNextLogin;
    }

    public boolean isMandatoryBeforeNextOrder() {
        return mandatoryBeforeNextOrder;
    }

    public void setMandatoryBeforeNextOrder(boolean mandatoryBeforeNextOrder) {
        this.mandatoryBeforeNextOrder = mandatoryBeforeNextOrder;
    }
}



